<template>
  <view class="page">
    <!-- 公共组件-每个页面必须引入 -->
    <public-module></public-module>

    <view class="u-padding-20" v-if="!userInfo.token">
      <u-empty :text="$t('nologin')" mode="permission"></u-empty>
    </view>

    <view class="" v-else>
	<!--u-loading-page :loading="loadstatus"></u-loading-page-->
    <u-empty :text="$t('nodata')"  mode="data"  icon="https://i.yodin.com/storage/empty/data.png" :show="flow_list.length === 0"  v-if="loadstatus == false" ></u-empty>
    <view class="" v-if="flow_list.length > 0">
        <view class="base-panel-box u-margin-20" v-for="(item, index) in flow_list" :key="index">
          <view class="htitle">
            <view class="u-font-sm">{{ item.create_time }}</view>
          </view>
          <view class="item" style="height: auto">
            <u-row gutter="0" justify="space-between">
              <u-col span="12">
                <view class="demo-layout bg-purple-light">{{ item.remark }}{{ item.info }}</view>
              </u-col>
            </u-row>
          </view>
        </view>

		<u-loadmore  v-if="flow_list.length > 0" nomoreText="End" color="#dddddd" marginBottom="50" marginTop="50" :status="loadStatus" @loadmore="getflowlist" line></u-loadmore>
		<u-gap height="10"></u-gap>
      </view>
    </view>
  </view>
</template>


<script>
import { mapState, mapMutations } from "vuex";
import { api_user_Actionlog } from '@/config/api.js';
export default {
  data() {
    return {
      flow_list: [],
      hasLogin: false,
      loadStatus: "loadmore",
      loadstatus: false,
      loadstxt: "loading...",
      page: 1,
    };
  },
  computed: {
    ...mapState(["userInfo"]),
  },
  onLoad(options) {
	uni.setNavigationBarTitle({title: this.$t('uesrlog')});
    this.getflowlist();
	
  },
  onReachBottom() {
	if (this.loadStatus=="loadmore"){
		setTimeout(() => {
		  if (this.loadStatus=='loadmore')this.getflowlist();
		}, 50);
	}
  },
  onPullDownRefresh() {
    this.flow_list = [];
    this.page = 1;
    this.getflowlist();

    setTimeout(() => {
      uni.stopPullDownRefresh();
    }, 500);
  },
  methods: {
    getflowlist() {
        this.loadstatus = true;
        api_user_Actionlog({
          page: this.page,
          limit: 10,
        }).then((res) => {
            this.loadstatus = false;
            if (res.count > 0) {
                if (this.page <= res.pages) {
					res.list.map((item) => {
						this.flow_list.push(item);
					})
					if (this.page==res.pages)this.loadStatus = "nomore";
                  this.page += 1;
                } else {
                  this.loadStatus = "nomore";
                }
            }
        }).catch((e) => {});
    },
  },
};
</script>
<style lang="scss" scoped>
	page{background: #f8f8f8;}
</style>
